//
//  ShareValue.m
//  PersonalCenter
//
//  Created by 李春阳 on 2018/5/17.
//  Copyright © 2018年 Yan Ding. All rights reserved.
//

#import "ShareValue.h"
static  NSString *UserIsLogin = @"UserIsLogin";

@implementation ShareValue
static ShareValue *_instance;

+ (ShareValue *)sharedInstance{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _instance = [[ShareValue alloc] init];
    });
    return _instance;
}

- (BOOL)isLogin{
    return [[NSUserDefaults standardUserDefaults] boolForKey:UserIsLogin];
}
- (void)setIsLogin:(BOOL)isLogin{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setBool:isLogin forKey:UserIsLogin];
    [defaults synchronize];
}


- (NSString *)phoneNum {
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"phone"] isKindOfClass:[NSNull class]]) {
        return @"";
    }
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"phone"];
}

- (void)setPhoneNum:(NSString *)phoneNum{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:phoneNum forKey:@"phone"];
    [defaults synchronize];
}

- (NSString *)userName {
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"userName"] isKindOfClass:[NSNull class]]) {
        return @"";
    }
    return [[NSUserDefaults standardUserDefaults] objectForKey:@"userName"];
}

- (void)setUserName:(NSString *)userName{
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:userName forKey:@"userName"];
    [defaults synchronize];
}

- (NSString *)password {
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"password"] isKindOfClass:[NSNull class]]) {
        return @"";
    }
    return [[NSUserDefaults standardUserDefaults]objectForKey:@"password"];
}

- (void)setPassword:(NSString *)password {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:password forKey:@"password"];
    [defaults synchronize];
}
@end
